<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Logger
 *
 * @author Royan
 */
class Logger
{
    //put your code here
    static public function trace( $message )
    {
        $message = date(DATE_ISO8601)." ".$message."\r\n";

        IF ( DEBUGGING === TRUE )
        {
            echo $message;
        }

        IF ( !file_exists( PATH_LOGFILE ) )
        {
            echo "file '".PATH_LOGFILE."' does not exist\r\n";
            throw new Exception( "file '".PATH_LOGFILE."' does not exist" );
        }
        ELSE
        {
            $fp = fopen( PATH_LOGFILE, "a" );

            IF ( !$fp )
            {

            }
            ELSE
            {
                    fwrite( $fp, $message );
                    fclose( $fp );
            }
        }
    }
}

?>
